Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
jest-haste-map
Advanced tools
The jest-haste-map npm package is a utility for building a Haste map, which is a mapping from module names to file paths. It is used by Jest to quickly resolve module dependencies for tests by keeping an in-memory map of all available modules. It can handle duplicate module names and provides a way to query the map for a specific module.
Building a Haste Map
This code sample demonstrates how to create a new HasteMap instance with a configuration object, build the map, and then use it to get the module name for a specific file.
const HasteMap = require('jest-haste-map');
const config = {
// These options are required:
roots: ['/path/to/project'],
extensions: ['js', 'json'],
platforms: ['ios', 'android'],
// You can provide additional options:
computeSha1: true,
// other options...
};
const hasteMap = new HasteMap(config);
hasteMap.build().then(map => {
console.log(map.hasteFS.getModuleName('/path/to/project/file.js'));
});
Querying the Haste Map
This code sample shows how to query the built Haste map for the path of a module given its name, platform, and whether it supports the native platform.
hasteMap.build().then(map => {
const modulePath = map.moduleMap.getModule('moduleName', 'platform', 'supportsNativePlatform');
console.log(modulePath);
});
Metro is a JavaScript bundler for React Native applications. It includes a Haste map implementation similar to jest-haste-map, but it is tailored specifically for React Native and includes additional features for bundling and transforming code.
Webpack is a powerful module bundler for JavaScript applications. While it does not use a Haste map, it provides a similar functionality through its own resolution mechanism, which can handle complex dependency graphs and offers a wide range of plugins for different tasks.
Browserify is a tool for bundling JavaScript files for usage in the browser. Like webpack, it does not use a Haste map, but it allows developers to require modules in the browser by bundling up all dependencies. It's simpler than webpack and may be more suitable for smaller projects.
29.7.0
[create-jest]
Add npm init
/ yarn create
initialiser for Jest projects (#14465)[jest-validate]
Allow deprecation warnings for unknown options (#14499)[jest-resolver]
Replace unmatched capture groups in moduleNameMapper
with empty string instead of undefined
(#14507)[jest-snapshot]
Allow for strings as well as template literals in inline snapshots (#14465)[@jest/test-sequencer]
Calculate test runtime if perStats.duration
is missing (#14473)[@jest/create-cache-key-function]
Cache access of NODE_ENV
and BABEL_ENV
(#14455)[jest-cli]
Move internal config initialisation logic to the create-jest
package (#14465)FAQs
Unknown package
We found that jest-haste-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.